﻿Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls
Imports System.Text
Imports System.IO
Imports System.Drawing
Imports System.Web

Public Class Menu
  Inherits Panel
  Implements IScriptControl

  Dim CampoPadreValor As String
  Public Property CampoPadre() As String
    Get
      Return CampoPadreValor
    End Get
    Set(ByVal value As String)
      CampoPadreValor = value
    End Set
  End Property

  Dim CampoIdValor As String
  Public Property CampoId() As String
    Get
      Return CampoIdValor
    End Get
    Set(ByVal value As String)
      CampoIdValor = value
    End Set
  End Property

  Dim CampoURLValor As String
  Public Property CampoURL() As String
    Get
      Return CampoURLValor
    End Get
    Set(ByVal value As String)
      CampoURLValor = value
    End Set
  End Property

  Dim CampoEtiquetaValor As String
  Public Property CampoEtiqueta() As String
    Get
      Return CampoEtiquetaValor
    End Get
    Set(ByVal value As String)
      CampoEtiquetaValor = value
    End Set
  End Property

  Dim CampoStatusValor As String
  Public Property CampoStatus() As String
    Get
      Return CampoStatusValor
    End Get
    Set(ByVal value As String)
      CampoStatusValor = value
    End Set
  End Property

  Dim RaizValor As String
  Public Property Raiz() As String
    Get
      Return RaizValor
    End Get
    Set(ByVal value As String)
      RaizValor = value
    End Set
  End Property

  Dim IdMenuValor As String
  Public Property IdMenu() As String
    Get
      Return IdMenuValor
    End Get
    Set(ByVal value As String)
      IdMenuValor = value
    End Set
  End Property

  Dim SeleccionandoValor As String
  Public Property Seleccionando() As String
    Get
      Return SeleccionandoValor
    End Get
    Set(ByVal value As String)
      SeleccionandoValor = value
    End Set
  End Property

  Dim HTMLEtiquetaValor As String = "b"
  Public Property HTMLEtiqueta() As String
    Get
      Return HTMLEtiquetaValor
    End Get
    Set(ByVal value As String)
      HTMLEtiquetaValor = value
    End Set
  End Property

  Dim TargetValor As String = String.Empty
  Public Property Target() As String
    Get
      Return TargetValor
    End Get
    Set(ByVal value As String)
      TargetValor = value
    End Set
  End Property

  Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)
    If Not Me.DesignMode Then
      Dim SM As ScriptManager = ScriptManager.GetCurrent(Page)
      If SM Is Nothing Then
        Throw New HttpException("Debe existir un ScriptManager el la pagina")
      Else
        SM.RegisterScriptControl(Me)
      End If
    End If
    MyBase.OnPreRender(e)
  End Sub
  Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
    If Not Me.DesignMode Then
      ScriptManager.GetCurrent(Me.Page).RegisterScriptDescriptors(Me)
    End If
    MyBase.Render(writer)
  End Sub
  Public Function GetScriptDescriptors() As System.Collections.Generic.IEnumerable(Of System.Web.UI.ScriptDescriptor) Implements System.Web.UI.IScriptControl.GetScriptDescriptors
    Dim descriptor As New ScriptControlDescriptor("MoniMisi2.Menu", Me.ClientID)
    Dim descriptors As New List(Of ScriptDescriptor)
    descriptor.AddProperty("IdMenu", IdMenu)
    descriptor.AddProperty("Raiz", Raiz)
    descriptor.AddProperty("CampoEtiqueta", CampoEtiqueta)
    descriptor.AddProperty("CampoURL", CampoURL)
    descriptor.AddProperty("CampoStatus", CampoStatus)
    descriptor.AddProperty("CampoPadre", CampoPadre)
    descriptor.AddProperty("CampoId", CampoId)
    descriptor.AddProperty("HTMLEtiqueta", HTMLEtiqueta)
    descriptor.AddProperty("Target", Target)
    If Seleccionando <> String.Empty Then
      descriptor.AddEvent("Seleccionando", Seleccionando)
    End If
    descriptors.Add(descriptor)
    Return descriptors
  End Function
  Public Function GetScriptReferences() As System.Collections.Generic.IEnumerable(Of System.Web.UI.ScriptReference) Implements System.Web.UI.IScriptControl.GetScriptReferences
    Dim scriptRef As New ScriptReference("MoniMisi2.Menu.js", Funciones.NombreCompletoEnsamblado(Me.GetType, "MoniMisi2.Menu"))
    scriptRef.NotifyScriptLoaded = False
    Dim scriptRefs As New List(Of ScriptReference)
    scriptRefs.Add(scriptRef)
    Return scriptRefs
  End Function
End Class
